import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:loxen/utils/app_enum_util.dart';
import 'package:loxen/utils/color.dart';
import 'package:loxen/utils/config.dart';
import 'package:loxen/utils/string_res.dart';
import 'package:loxen/view/mine/staff_order_list_page.dart';
import 'package:loxen/widget/my_subassembly.dart';

class StaffOrderListWidget extends StatefulWidget {
  @override
  _StaffOrderListWidgetState createState() => _StaffOrderListWidgetState();
}

class _StaffOrderListWidgetState extends State<StaffOrderListWidget> with TickerProviderStateMixin {
  final List<Tab> tabs = [
    Tab(
      text: '全部',
    ),
    Tab(
      text: '待备样',
    ),
    Tab(
      text: '待送样',
    ),
    Tab(
      text: '已完成',
    ),
  ];

  final ValueNotifier<int> index = ValueNotifier(0);
  TabController controller;

  @override
  void initState() {
    super.initState();
    controller = TabController(initialIndex: 0, length: tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Theme.of(context).backgroundColor,
      appBar: PreferredSize(
        preferredSize: Size(double.infinity, 96.h),
        child: Container(
          color: Theme.of(context).backgroundColor,
          child: SafeArea(
            child: Column(
              children: [
                Row(
                  children: <Widget>[
                    MySubassembly.getBackIcon(context,
                        color: Theme.of(context).textTheme.subtitle2.color),
                    Expanded(
                      child: Center(
                        child: Text(
                          StringResources.ri_cheng,
                          style: TextStyle(
                              fontSize: 32.sp,
                              fontWeight: FontWeight.w500,
                              color: Theme.of(context).textTheme.subtitle2.color),
                        ),
                      ),
                    ),
                    MySubassembly.getSearchIcon(null, text: Constants.empty),
                  ],
                ),
                Divider(height: 1.h)
              ],
            ),
          ),
        ),
      ),
      body: Column(
        children: [
          TabBar(
            isScrollable: false,
            onTap: (index) {
              this.index.value = index;
            },
            indicator: UnderlineTabIndicator(
              borderSide: BorderSide(color: Colours.app_main, width: 3.h),
              insets: EdgeInsets.fromLTRB(50.w, 0, 50.w, 0),
            ),
            unselectedLabelColor: Colours.main_text,
            labelColor: Colours.app_main,
            labelStyle: TextStyle(
              fontSize: 29.sp,
              fontWeight: FontWeight.bold,
            ),
            controller: controller,
            tabs: tabs,
          ),
          Expanded(
            child: TabBarView(controller: controller, children: [
              StaffOrderListPage(staffType: StaffType.ALL),
              StaffOrderListPage(staffType: StaffType.SAMPLE_TO_BE_PREPARED),
              StaffOrderListPage(staffType: StaffType.SAMPLE_TO_BE_SENT),
              StaffOrderListPage(staffType: StaffType.COMPLETED),
            ]),
          )
        ],
      ),
    );
    ;
  }
}
